package com.mingtu.jgspatrol.adapter;

import android.content.Context;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.StringUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mingtu.jgspatrol.R;
import com.mingtu.jgspatrol.bean.SendTaskListBean;

public class SendFinishTaskAdapter extends BaseQuickAdapter<SendTaskListBean.PageBean.ListBean, BaseViewHolder> {
    private Context context;

    public SendFinishTaskAdapter(Context context) {
        super(R.layout.item_my_send_task);
        this.context = context;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, SendTaskListBean.PageBean.ListBean listBean) {
        String taskName = listBean.getName();
        String createTime = listBean.getCreateTime();
        String finishTime = listBean.getFinishTime();
        int type = 2; //1：巡护任务 2：临时指派任务

        if (!StringUtils.isEmpty(taskName)) {
            helper.setText(R.id.tv_task_name, taskName);
        }

        if (!StringUtils.isEmpty(createTime)) {
            helper.setText(R.id.tv_create_time, createTime);
        }

        if (!StringUtils.isEmpty(finishTime)) {
            helper.setText(R.id.tv_end_time, finishTime);
        }

        if (type == 1) {
            helper.setText(R.id.tv_task_type, "巡护");

        } else if (type == 2) {
            helper.setText(R.id.tv_task_type, "下发");
            helper.getView(R.id.tv_task_type).setBackground(context.getDrawable(R.drawable.shape_bg_task_type2));
            helper.setTextColor(R.id.tv_task_type, context.getResources().getColor(R.color.bg_color_519));
        }
    }


}
